﻿app.controller('RegisterController', ['$scope', '$location', 'RegisterFactory', function ($scope, $location, RegisterFactory) {
    $scope.newUser = {};

    $scope.addAccount = function () {
        RegisterFactory.addAccount($scope.newUser);
        // $scope.newUser = {};
    };
}]);

//var RegisterController = function ($scope, LoginFactory, RegisterFactory) {
//    $scope.registerForm = {
//        username: undefined,
//        userEmail: undefined,
//        password: undefined,
//        confirmPassword: undefined,
//        errorMessage: undefined
//    };

//    $scope.register = function () {
//        RegisterFactory($scope.registerForm.username, $scope.registerForm.password, $scope.registerForm.confirmPassword)
//		.then(function () {
//		    LoginFactory($scope.registerForm.username, $scope.registerForm.password)
//			.then(function (response) {
//			    SessionService.setToken(response.access_token);
//			}, function (response) {
//			    $scope.loginForm.errorMessage = response;
//			});
//		}, function (response) {
//		    $scope.registerForm.errorMessage = response;
//		});
//    }
//}
//RegisterController.$inject = ['$scope', 'LoginFactory', 'RegisterFactory'];